<!-- 菜单 -->
<div th:fragment="menu">
    <div id="sidebar">
        <ul id="menu">

        </ul>
    </div>
    <script type="text/javascript" th:src="@{/js/jquery-1.11.2.min.js}"></script>
    <script type="text/javascript">
        $.ajax({
            catch:true,
            type:"POST",
            url:'resources/loadMenu.do',
            dataType:"JSON",
            success:function (data) {
                var html = "";
                for (var i=0;i<data.length;i++){
                    html+="<li><a href='"+data[i].resUrl+"'><i class='icon icon-home'></i> <span>"+data[i].name+"</span></a> </li>"
                }
                $("#menu").append(html);

                //改变当前菜单样式
                /*$("menu li a").each(function () {
                    $this = $(this);
                    if ($this[0].href == String(window.location)){
                        $this.attr("href","javascript");
                        $this.parent().addClass("active");
                    }
                })*/
                $("#menu li a").each(function(){
                    $this = $(this);
                    if($this[0].href==String(window.location)){
                        $this.attr("href","javascript:;");
                        $this.parent().addClass("active");
                    }
                });
            }
        });
    </script>

</div>
<!-- 结束菜单 -->